package nz.ac.massey.doi_information_extractor.tests;

import static org.junit.Assert.*;

import java.net.Authenticator;
import nz.ac.massey.doi_information_extractor.data.Publication;
import nz.ac.massey.doi_information_extractor.parser.ParserEngine;
import nz.ac.massey.doi_information_extractor.parser.PublicationNotFoundException;

import org.junit.Before;
import org.junit.Test;


public class ParserEngineTest {

	Publication pub;
	
	@Before
	public void setUp(){
		System.setProperty("http.proxyHost", "tur-cache.massey.ac.nz");
		System.setProperty("http.proxyPort", "8080");
		Authenticator.setDefault(new TestAuthenticator());
	}
	
	@Test
	public void testResults() throws Exception{
		String doi = "10.1016/j.websem.2006.11.007";
		ParserEngine engine = new ParserEngine();

		pub = engine.getInformationFromDOI(doi);
		
		assertTrue(pub.getArticleTitle().equals("Towards a web of patterns"));
		}
	
	@Test(expected=PublicationNotFoundException.class)
	public void testException() throws Throwable {
		String doi = "blah/blah";
		ParserEngine engine = new ParserEngine();
		pub = engine.getInformationFromDOI(doi);
		System.out.print("Shouldn't get this far! But if it does, the DOI was " + doi);
	}
}
